const path = require('path');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
module.exports = {
    entry: {
        main: './src/index.js',
        style:'./src/style.js'
    }
    ,
    output: {
        filename: 'js/[name].js',
        path: path.resolve(__dirname, 'dist'),
        publicPath:"http://127.0.0.1:8080/"
    },
    plugins:[
        new HtmlWebpackPlugin({
            filename:"index.html",
            template:"index.html",
            inject:"head",
            minify:{
                collapseWhitespace:true,//去掉空格
                minifyCSS:true,
                minifyJs:true,
                ignoreCustomComments:true//去掉注释
            }
        }),
        new UglifyJsPlugin()
    ],
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    {
                        loader: 'style-loader'
                    },
                    {
                        loader: 'css-loader',
                        options: {
                            minimize: true //css压缩
                        }
                    }
                    
                ]
            }
        ]
    }
};